<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>成绩管理</title>
	<link rel="stylesheet" href="../css/common2.css">
	<style>
		.issue {
			margin-left: 190px;
			margin-top: -36px;
			position: relative;
		}

		.course {
			margin-left: 400px;
			margin-top: -36px;
			position: relative;
		}

		.class {
			margin-left: 610px;
			margin-top: -36px;
			position: relative;
		}

		.search_img {
			position: absolute;
			margin-top: 0;
			right: 3%;
		}

		.search {
			margin-top: 23px;
		}

		.import {
			width: 120px;
			height: 35px;
			background: #3fb9e3;
			text-align: center;
			font-size: 18px;
			line-height: 35px;
			color: white;
			border-radius: 12px;
			float: left;
			position: relative;
			margin-left: 55px;
		}

		.export {
			width: 120px;
			height: 35px;
			background: #3fb9e3;
			text-align: center;
			font-size: 18px;
			line-height: 35px;
			color: white;
			border-radius: 12px;
			float: left;
			position: relative;
			margin-left: 50px;
		}

		.one {
			width: 10%;
		}

		.two {
			width: 15%;
		}

		.three {
			width: 9%;
		}

		.long-background-img {
			width: 120px;
			height: 35px;
			margin-left: 10px;
			background: url("../image/enter_longer.png") no-repeat center center !important;
		}

		.action-buttons:nth-child(1) {
			margin-left: 2%;
		}
	</style>
</head>

<body>
	<div id="vue-root" style="margin-top: 30px;">
		<div v-if="able.add" class="add action-buttons">
			<a href="educational_score_item.html" style="color: white">添加成绩</a>
		</div>
		<div v-if="able.add" class="add action-buttons" style="margin-left: calc(2% - 20px);">
			<a href="educational_term.html" style="color: white">添加期号</a>
		</div>
		<form enctype="multipart/form-data" id="form" ref="form" style="display: none;">
			<input type="file" name="file" id="file" @change="importExcel" ref="file"
				accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel">
		</form>
		<div class="refresh action-buttons" onclick="location.reload()">刷新</div>
		<input placeholder="请输入名字" class="search" v-model="search.studentName"
			style="position: absolute; right: 565px;width: 120px; height: 33px;margin-top: 0;">
		<div class="issue">
			<select class="search" v-model="search.termId" style="position: absolute; right: 410px;margin-top: 0;">
				<option :value="undefined">请选择期号</option>
				<option v-for="term in terms" :key="term.id" :value="term.id" v-text="term.name"></option>
			</select>
		</div>
		<div class="course">
			<select class="search" v-model="search.courseId" style="position: absolute; right: 255px;margin-top: 0;">
				<option :value="undefined">请选择课程</option>
				<option v-for="course in courses" :key="course.id" :value="course.id" v-text="course.name"></option>
			</select>
		</div>
		<div class="class">
			<select class="search" v-model="search.classesId" style="position: absolute; right: 100px;margin-top: 0;">
				<option :value="undefined">请选择班级</option>
				<option v-for="classes in classess" :key="classes.id" :value="classes.id" v-text="classes.name">
				</option>
			</select>
		</div>

		<img src="../image/search.png" height="35" width="35" class="search_img" @click="getData0">


		<div class="table" style="margin-top: 60px;">
			<table class="table_top">
				<thead>
					<tr>
						<th class="one">
							<input type="checkbox" class="check-box" v-model="all">
						</th>
						<th>序号</th>
						<th class="two">期号</th>
						<th class="two">班级</th>
						<th class="two">学号</th>
						<th class="one">姓名</th>
						<th class="two">课程</th>
						<th class="one">成绩</th>
						<th class="three">编辑/删除</th>
					</tr>
				</thead>
				<tbody id="list">
					<tr v-for="(score,index) in list" :key="score.id">
						<td class="one">
							<input type="checkbox" class="check-box" v-model="score.checked">
						</td>
						<td><span v-text="index+1"></span></td>
						<td class="two" v-text="score.termName"></td>
						<td class="two" v-text="score.classesName"></td>
						<td class="two" v-text="score.studentNo"></td>
						<td class="one" v-text="score.studentName"></td>
						<td class="two" v-text="score.courseName"></td>
						<td class="one" v-text="score.score"></td>
						<td class="three">
							<div class="option">
								<div v-if="able.edit" class="edit-icon option-icon">
									<a :href="'educational_score_item.html?id='+score.id"
										style="left: 20%; top:30%;position: absolute;">
										<img class="img" src="../image/edit.png" height="20" width="20"
											onmouseover="this.src='../image/edit_light.png'"
											onmouseout="this.src='../image/edit.png'" />
									</a>
								</div>
								<div v-if="able.del" class="delete-icon option-icon" @click="del([score.id])"
									style="right: 20%; top:30%;position: absolute;">
									<img class="img" src="../image/delete.png" height="20" width="20"
										onmouseover="this.src='../image/delete_light.png'"
										onmouseout="this.src='../image/delete.png'" />
								</div>
							</div>
						</td>
					</tr>

				</tbody>
			</table>
		</div>
		<br>
		<div v-if="able.del" class="delete" @click="batchDelete">批量删除</div>
		<a v-if="able.add" href="/excel/score.xls">
			<div class="delete long-background-img">下载导入模板</div>
		</a>
		<label v-if="able.add" class="delete long-background-img" for="file">批量导入成绩</label>
		<div class="delete long-background-img" @click="exports">批量导出成绩</div>
		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum--">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>
		</ul>
	</div>

	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>
	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>
	<script src="/js/auth_util.js"></script>

	<script>
		var app = new Vue(merge({
			data: {
				urls: {
					del: '/pc/score/del'
				},
				terms: [],
				courses: [],
				classess: []
			},
			created: function () {
				var schoolId = top_params().id;
				if (!schoolId) {
					alert('未知学校');
					throw '未知学校';
				}
				this.schoolId = schoolId;
				this.urls.list = '/pc/score/list/' + schoolId;
				this.urls.imports = '/pc/score/import/' + schoolId;
				this.getData();

				var _this = this;

				axios.get('/pc/term/all/' + schoolId).then(function (res) {
					_this.terms = res.data;
				});
				axios.get('/pc/classes/all/' + schoolId).then(function (res) {
					_this.classess = res.data;
				});
				axios.get('/pc/course/all/' + schoolId).then(function (res) {
					_this.courses = res.data;
				});
				abled('score', this);
			},
			methods: {
				exports: function () {
					var q = Qs.stringify(this.search);
					if (q) q = '?' + q;
					location.href = '/pc/score/export/' + this.schoolId + q;
				}
			}
		}));
	</script>

</body>

</html>